<template>
  <div v-if="renderValue">
    <el-link type="primary"
             @click="goDetail">{{ renderValue }}</el-link>
    <DetailCom ref="detailCom" :curRow="curRow"/>
  </div>
</template>

<script setup lang="ts">
import { TableColumnCtx } from 'element-plus'
import { inject, ref } from 'vue'
import type baTableClass from '/@/utils/baTable'
import DetailCom from './detailCom.vue'
const detailCom: any = ref<InstanceType<typeof DetailCom>>()
const baTable = inject('baTable') as baTableClass
const curRow = ref({} as anyObj)
// 自定义

// BuildAdmin将自动为此组件传递五个Props
interface Props {
    renderValue: any // 单元格值
    renderRow: TableRow // 当前行数据
    renderField: TableColumn // 当前列数据
    renderColumn: TableColumnCtx<TableRow> // 当前列上下文数据
    renderIndex: number // 当前行号
}
const props = defineProps<Props>()
const goDetail = () => {
    const obj:anyObj = {}
    baTable.table.filter?.search!.forEach(v => {
        obj[v.field] = v.val
    }) || []
    curRow.value.search = { ...obj }
    curRow.value.rowData = { ...props.renderRow }
    detailCom.value.show = true
}
// console.log(props.renderValue, props.renderRow, props.renderField, props.renderColumn, props.renderIndex)
</script>

<style scoped lang="scss">
// 自定义
</style>